char r[1000][1001],s[1001];f(char*a,char*b){return strcmp(a,b);}main(i,c,n,l,t){for(i=c=0,gets(&n);~scanf("%d%s",&n,s);){for(l=strlen(s)+1,i=0;i<l-n;i++)strncpy(r[i],s+i,n),r[i][n]=0;qsort(*r,l-n,1001,f);printf("Case #%d:\n",++c);for(*s=0,t=i=0;i<l-n+1;i++)if(strcmp(s,r[i]))printf(*s?"%s %d\n":"",s,i-t),t=i,strcpy(s,r[i]);}}
